Fix go-ts-mode const_spec highlighting (Bug#76330)
authorRandy Taylor <dev@rjt.dev>
Sun, 16 Feb 2025 20:51:43 +0000 (15:51 -0500)
committerEli Zaretskii <eliz@gnu.org>
Sat, 1 Mar 2025 12:12:30 +0000 (14:12 +0200)
* lisp/progmodes/go-ts-mode.el (go-ts-mode--font-lock-settings):
Handle multiple const_spec identifiers.
* test/lisp/progmodes/go-ts-mode-resources/font-lock.go:
Add test case.

lisp/progmodes/go-ts-mode.el
test/lisp/progmodes/go-ts-mode-resources/font-lock.go

index 5110ab890f3dc06965f64f3bca9c1a218819b0f2..eb5b93008ebf5aa36225c95cef35267db6250790 100644 (file)
      ,@(when (go-ts-mode--iota-query-supported-p)
          '((iota) @font-lock-constant-face))
      (const_declaration
-      (const_spec name: (identifier) @font-lock-constant-face)))
+      (const_spec name: (identifier) @font-lock-constant-face
+                  ("," name: (identifier) @font-lock-constant-face)*)))
 
    :language 'go
    :feature 'delimiter
index 4e7a8e1710ba1785e656784fcfe5b49bcc67d0ba..170bf9353c65c4697c4c4af8fe4cc69565d031dd 100644 (file)
@@ -3,3 +3,9 @@ for idx, val := range arr {}
 //        ^ font-lock-variable-name-face
 for idx := 0; idx < n; idx++ {}
 //   ^ font-lock-variable-name-face
+
+const (
+       zero, one = 0, 1
+//      ^ font-lock-constant-face
+//            ^ font-lock-constant-face
+)